<?php
$this->Html->css('plugins/data-tables/DT_bootstrap', array('block'	=>	'css'));
$this->Html->script(array('plugins/data-tables/jquery.dataTables', 
						  'plugins/data-tables/DT_bootstrap',
						  'scripts/custom/table-editable'), 
					array('block'	=>	'scriptfooter'));
?>

<div class="row">
				<div class="col-md-12">
					<div class="table-toolbar">
						<div class="btn-group">
							<a href="<?php
									echo $this->Html->url(array('controller'	=>	'users', 'action'	=>	'admin_add'), true);
									?>" id="sample_editable_1_new" class="btn green">
									Add New <i class="fa fa-plus"></i>
							</a>
						</div>
					</div>

					<table class="table table-striped table-hover table-bordered" id="sample_editable_1">
							<thead>
							<tr>
								<th>
									 <?php echo $this->Paginator->sort('username'); ?>
								</th>
								<th>
									 Full Name
								</th>
								<th>
									 <?php echo $this->Paginator->sort('role'); ?>
								</th>
								<th>
									 Edit
								</th>
								<th>
									 Delete
								</th>
							</tr>
							</thead>
							<tbody>
								<?php
								foreach ($users as $k => $val) 
								{
									$user = $val['User'];
									echo '<tr>
											<td '.(($user['active'] == 0) ? 'style="text-decoration: line-through;"' : '').'>
												 '.$user['username'].'
											</td>
											<td>
												 '.$user['firstname'].' '.$user['lastname'].'
											</td>
											<td>
												 '.$user['role'].'
											</td>											
											<td>
												<a class="edit" href="'.$this->Html->url(array('controller'	=> 'users', 'action'	=>	'admin_edit', $user['id']), true).'">
													 Edit
												</a>
											</td>
											<td>
											'.$this->Form->postLink(
							                    'Delete',
							                    array('action' => 'admin_delete', $user['id']),
							                    array('confirm' => 'Are you sure?')
							                ).'
												
											</td>
										</tr>';
								}
								?>
							
							</tbody>
							</table>
							<p>
	<?php
	echo $this->Paginator->counter(array(
	'format' => __('Page {:page} of {:pages}, showing {:current} records out of {:count} total, starting on record {:start}, ending on {:end}')
	));
	?>	</p>
	<div class="paging">
	<?php
		echo $this->Paginator->prev('< ' . __('previous'), array(), null, array('class' => 'prev disabled'));
		echo $this->Paginator->numbers(array('separator' => ''));
		echo $this->Paginator->next(__('next') . ' >', array(), null, array('class' => 'next disabled'));
	?>
	</div>
				</div>
			</div>
<script>
jQuery(document).ready(function() {       
   //TableEditable.init();
});
</script>